package com.ynunicom.midplatform.sys.role;

import com.ynunicom.midplatform.common.persistence.entity.AbstractIdEntity;
import com.ynunicom.midplatform.sys.permission.SysPermission;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.util.List;

/**
 * 系统角色表
 *
 * @author duwei
 */
@Entity
@Table(name = "sys_role")
@Getter
@Setter
public class SysRole extends AbstractIdEntity {


    private String name;

    @Column(unique = true)
    private String code;
    /**
     * 角色描述,UI界面显示使用
     */
    private String description;
    /**
     * 是否可用,如果不可用将不会添加给用户
     */
    private Boolean available = Boolean.FALSE;

    @ManyToMany(fetch = FetchType.EAGER)
    @JoinTable(name = "SysRolePermission", joinColumns = {@JoinColumn(name = "roleId")}, inverseJoinColumns = {@JoinColumn(name = "permissionId")})
    private List<SysPermission> permissions;

}